package web{
	import flash.events.Event;
	import flash.events.MouseEvent;
	import morn.core.handlers.Handler;
	import ui.down.AlertUI;
	/**
	 * ...
	 * @author SXL
	 */
	public class WebAlert extends AlertUI{
		
		private static var _instance:WebAlert;
		public static function get instance():WebAlert{
            if (!_instance){
                _instance = new WebAlert();
            }
            return _instance;
        }
		private var callback:Handler;
		/**开始弹出消息*/
		public function start(msg:String,callback:Handler=null):void{
			this.tfInfo.text=msg;
			this.callback=callback;
			App.dialog.popup(this);
			this.addEventListener(MouseEvent.CLICK,this.onStageClick);
			this.addEventListener(Event.REMOVED_FROM_STAGE,this.onRemvoedFromStage);
		}
		private function onStageClick(evt:MouseEvent):void{
			var name:String=evt.target.name;
			switch(name){
				case "btOK":
					this.close();
					if(this.callback)this.callback.execute();
					break;
				case "btEsc":
				case "btClose":
					this.close();
					break;
			}
		}
		private function onRemvoedFromStage(evt:Event):void{
			this.removeEventListener(MouseEvent.CLICK,this.onClick);
			this.removeEventListener(Event.REMOVED_FROM_STAGE,this.onRemvoedFromStage);
		}
	}
}